<template>
  <div>
    <div class="head">
      <div class="flex">
        <el-button @click="back" icon="el-icon-arrow-left">返回</el-button>
        <span style="margin-left: 10px">新增学员</span>
      </div>
      <div class="input">
        <span>姓名：</span>
        <el-input v-model="queryData.name" placeholder="请输入" />
      </div>
      <div class="input">
        <span>身份证号：</span>
        <el-input v-model="queryData.idCard" placeholder="请输入" />
      </div>
      <div class="input">
        <span>人员类别：</span>
        <el-select v-model="queryData.type" placeholder="请选择">
          <el-option label="类别1" :value="1">类别1</el-option>
          <el-option label="类别2" :value="2">类别2</el-option>
        </el-select>
      </div>
      <div class="input">
        <span>职务/工种：</span>
        <el-select v-model="queryData.type2" placeholder="请选择">
          <el-option label="工种1" :value="1">工种1</el-option>
          <el-option label="工种2" :value="2">工种2</el-option>
        </el-select>
      </div>
      <el-button type="primary" class="btn" @click="search">查询</el-button>
      <el-button type="primary" class="btn" @click="reset">重置</el-button>
    </div>
    <div class="box">
      <el-table
        :data="tableData"
        border
        v-loading="isTableLoading"
        empty-text="暂无数据"
        no-filtered-userFrom-text="暂无筛选结果"
        style="width: 100%"
      >
        <el-table-column fixed type="selection" align="center" label="序号" width="50" />
        <el-table-column fixed prop="name" align="center" label="姓名" min-width="130" />
        <el-table-column prop="idCard" align="center" label="证件号码" width="160" />
        <el-table-column prop="phone" align="center" label="手机号" width="130"></el-table-column>
        <el-table-column prop="isReal" align="center" label="实名认证" width="120">
          <template #default="scope">
            {{ scope.row.isReal ? '已认证' : '未认证' }}
          </template>
        </el-table-column>
        <el-table-column prop="total" align="center" label="课件总数" width="100"></el-table-column>
        <el-table-column prop="complete" align="center" label="已完成课件数" width="100"></el-table-column>
        <el-table-column prop="status" align="center" label="学习状态" width="100">
          <template #default="scope">
            {{ scope.row.status == 1 ? '未学习' : '学习中' }}
          </template>
        </el-table-column>
        <el-table-column prop="test" align="center" label="考试情况" width="100"></el-table-column>
        <el-table-column prop="img" align="center" label="证件照片" width="140">
          <template #default="scope">
            <img :src="scope.row.img" v-if="scope.row.img" style="width: 100px; height: 100px" />
          </template>
        </el-table-column>
        <el-table-column fixed="right" align="center" prop="action" label="操作" width="240">
          <template #default="scope">
            <div class="action">
              <span>查看</span>
              <span>下载培训档案</span>
              <span>从本班移除</span>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        style="margin-top: 5px"
        @size-change="search"
        @current-change="search"
        :current-page.sync="queryData.page"
        :page-size.sync="queryData.size"
        layout="total, prev, pager, next,sizes,jumper"
        :total="total"
      >
      </el-pagination>
    </div>

    <div class="footer">
      <el-button type="primary">确认</el-button>
      <el-button @click="back" type="primary">取消</el-button>
    </div>
  </div>
</template>

<script>
import { dateFormat } from '../../libs/util';
export default {
  name: 'cultivate',
  data() {
    return {
      queryData: {
        name: '',
        idCard: '',
        type: '',
        type2: '',
        page: 1,
        size: 10,
      },
      total: 0,
      isTableLoading: false,
      tableData: [],
      dialogVisible: false,
    };
  },
  computed: {},
  created() {},
  mounted() {
    this.getList();
  },
  methods: {
    search() {
      this.queryData.page = 1;
      this.getList();
    },
    reset() {
      this.queryData.name = '';
      this.queryData.idCard = '';
      this.queryData.type = '';
      this.queryData.type2 = '';
      this.search();
    },
    add() {
      this.$router.push({
        path: '/company/addStudent/index',
      });
    },
    getList() {
      console.log(this.queryData);

      this.isTableLoading = true;
      this.tableData = [
        {
          id: 1,
          name: '玛丽',
          idCard: '6666**********8888',
          phone: '12345678901',
          isReal: 0,
          total: 9,
          complete: 0,
          status: 1,
          test: '',
          img: '',
        },
        {
          id: 2,
          name: '玛丽',
          idCard: '6666**********8888',
          phone: '12345678901',
          isReal: 1,
          total: 9,
          complete: 0,
          status: 3,
          test: '合格',
          img: '',
        },
      ];
      this.total = 2;
      this.isTableLoading = false;
    },
    back() {
      this.$router.back();
    },
  },
};
</script>

<style scoped>
.head {
  width: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  background: #ffffff;
  border-radius: 5px;
  padding: 20px;
  padding-bottom: 0px;
}
.input {
  display: flex;
  align-items: center;
  margin-right: 15px;
  margin-bottom: 20px;
}
.input > span {
  font-size: 12px;
  flex-shrink: 0;
}
.btn {
  margin-bottom: 20px;
}
.box {
  width: 100%;
  background: #ffffff;
  border-radius: 5px;
  padding: 20px;
  margin-top: 20px;
}
.action {
  display: flex;
  align-items: center;
  justify-content: center;
}
.action span {
  color: #0256ff;
  font-size: 12px;
  cursor: pointer;
  margin: 0 8px;
}
.flex {
  width: 100%;
  align-items: center;
  margin-bottom: 20px;
}
.footer {
  width: 100%;
  height: 60px;
  position: fixed;
  bottom: 0px;
  left: 0;
  z-index: 9;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 210px;
  border-top: 1px solid #e6e6e6;
}
</style>
